<?php 

require("../include/config.php");
require("../API/php/fonctions.php");
require("../API/php/header.php");

$modeDebug = false;

// phpsql/mysql_getIndReport1.php?milis=123456789&crtl=ok

//[0][0] = recu12mois
//[1][0] = fermé12mois
//[2][0] = month0
//[2][1] = month1
//[2][2] = month2
//[2][3] = month3
//[3][0] = recuMois0
//[4][0] = recuMois1
//[5][0] = recuMois2
//[6][0] = recuMois3
//[7][0] = fermeMois0
//[8][0] = fermeMois1
//[9][0] = fermeMois2
//[10][0] = fermeMois3
//[11][0] = nbTocPourAquit
//[12][0] = nbTocAquit
//[13][0] = percAquit
//[14][0] = nbTocPourAquit0
//[15][0] = nbTocAquit0
//[16][0] = percAquit0
//[17][0] = nbTocPourAquit1
//[18][0] = nbTocAquit1
//[19][0] = percAquit1
//[20][0] = nbTocPourAquit2
//[21][0] = nbTocAquit2
//[22][0] = percAquit2
//[23][0] = nbTocPourAquit3
//[24][0] = nbTocAquit3
//[25][0] = percAquit3
//[26][0] = nbTocP1
//[27][0] = nbTocP1D
//[28][0] = percSLAP1
//[29][0] = nbTocP10
//[30][0] = nbTocP1D0
//[31][0] = percSLAP10
//[32][0] = nbTocP11
//[33][0] = nbTocP1D1
//[34][0] = percSLAP11
//[35][0] = nbTocP12
//[36][0] = nbTocP1D2
//[37][0] = percSLAP12
//[38][0] = nbTocP13
//[39][0] = nbTocP1D3
//[40][0] = percSLAP13

//[41][0] = nbTocP2
//[42][0] = nbTocP2D
//[43][0] = percSLAP2
//[44][0] = nbTocP20
//[45][0] = nbTocP2D0
//[46][0] = percSLAP20
//[47][0] = nbTocP21
//[48][0] = nbTocP2D1
//[49][0] = percSLAP21
//[50][0] = nbTocP22
//[51][0] = nbTocP2D2
//[52][0] = percSLAP22
//[53][0] = nbTocP23
//[54][0] = nbTocP2D3
//[55][0] = percSLAP23

//[56][0] = nbTocP34
//[57][0] = nbTocP34D
//[58][0] = percSLAP34
//[59][0] = nbTocP340
//[60][0] = nbTocP34D0
//[61][0] = percSLAP340
//[62][0] = nbTocP341
//[63][0] = nbTocP34D1
//[64][0] = percSLAP341
//[65][0] = nbTocP342
//[66][0] = nbTocP34D2
//[67][0] = percSLAP342
//[68][0] = nbTocP343
//[69][0] = nbTocP34D3
//[70][0] = percSLAP343

//[71][0] = reste12mois
//[72][0] = reste1
//[73][0] = reste2
//[74][0] = reste3

//[75][0] = ratio

//[76][0] = stockCgi0
//[77][0] = horsStockCgi0

// IN obligatoire
$arrayGet = array(
    "crtl" => null
);

$arrayValeur = recupGet($arrayGet, $bolDecode);

if($arrayValeur["error"] == null){
	// CONNECION SQL
	$db = mysql_connect($host, $base, $mdp)  or die('Erreur de connexion '.mysql_error());
        mysql_query("SET NAMES UTF8"); 

	// CONNECION BASE
	mysql_select_db($base,$db)  or die('Erreur de selection '.mysql_error());
	
	//Nombre de ticket et d'incident reçu cumulé sur 12 mois
	$sql = "select count(*) as `recu12mois` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`date_creation` between (now() - interval 1 year) and now()
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['recu12mois']
		.'&'
		."\r\n"; 
	}
	
	//Nombre de ticket et d'incident fermé cumulé sur 12 mois
	$sql = "select count(*) as `fermé12mois` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['fermé12mois']
		.'&'
		."\r\n"; 
	}
	
	//Les mois 
	$sql = "SELECT DATE_FORMAT(NOW(),'%b-%y') as month0, 
		date_format(now() - interval 1 MONTH,'%b-%y') as month1, 
		date_format(now() - interval 2 MONTH,'%b-%y') as month2, 
		date_format(now() - interval 3 MONTH,'%b-%y') as month3
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['month0'].'&'.$data['month1'].'&'.$data['month2'].'&'.$data['month3']
		.'&'
		."\r\n"; 
	}
	
	
	//les entrants sur les mois
	$sql = "select count(*) as `recuMois0` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['recuMois0']
		.'&'
		."\r\n"; 
	}
	
	//les entrants sur les mois
	$sql = "select count(*) as `recuMois1` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['recuMois1']
		.'&'
		."\r\n"; 
	}
	
	//les entrants sur les mois
	$sql = "select count(*) as `recuMois2` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['recuMois2']
		.'&'
		."\r\n"; 
	}
	
	//les entrants sur les mois
	$sql = "select count(*) as `recuMois3` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND date_format(a.`date_creation`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_creation` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['recuMois3']
		.'&'
		."\r\n"; 
	}
	
	//les fermé sur les mois
	$sql = "select count(*) as `fermeMois0` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' )
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['fermeMois0']
		.'&'
		."\r\n"; 
	}
	
	//les fermé sur les mois
	$sql = "select count(*) as `fermeMois1` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' )
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['fermeMois1']
		.'&'
		."\r\n"; 
	}
	
	//les fermé sur les mois
	$sql = "select count(*) as `fermeMois2` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' )
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['fermeMois2']
		.'&'
		."\r\n"; 
	}
	
	//les fermés sur les mois
	$sql = "select count(*) as `fermeMois3` from `vm_inventaire_tocs` a
		where 1=1
		AND a.`revision` = 0
		AND a.`emis` != 'Oui'
		AND a.`statut` = 'Fermé'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT b.responsable FROM `effectifs` b WHERE 1=1
			AND b.date_in != '0000-00-00' 
			AND b.date_out != '0000-00-00' )
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$strSorti .= $data['fermeMois3']
		.'&'
		."\r\n"; 
	}
	
	//======================= AQUITEMENT
	
	//nombre de ticket pour l'aquit total sur 12mois
	$sql = "SELECT COUNT(*) as nbTocPourAquit FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`date_recept` between (now() - interval 1 year) and now()
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocPourAquit = $data['nbTocPourAquit'];
		$strSorti .= $data['nbTocPourAquit']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT COUNT(*) as nbTocAquit FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`time_aquit` <= '01:00:00'
		AND a.`date_recept` between (now() - interval 1 year) and now()
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocAquit = $data['nbTocAquit'];
		$strSorti .= $data['nbTocAquit']
		.'&'
		."\r\n"; 
	}
	
	$percAquit = round(($nbTocAquit / $nbTocPourAquit) * 100,2);
	$strSorti .= $percAquit
	.'&'
	."\r\n";
	
	//==============
	
	//nombre de ticket pour l'aquit total sur 12mois
	$sql = "SELECT COUNT(*) as nbTocPourAquit0 FROM vm_durees_etapes a
		WHERE 1=1
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocPourAquit0 = $data['nbTocPourAquit0'];
		$strSorti .= $data['nbTocPourAquit0']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT COUNT(*) as nbTocAquit0 FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`time_aquit` <= '01:00:00'
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocAquit0 = $data['nbTocAquit0'];
		$strSorti .= $data['nbTocAquit0']
		.'&'
		."\r\n"; 
	}
	
	$percAquit0 = round(($nbTocAquit0 / $nbTocPourAquit0) * 100,2);
	$strSorti .= $percAquit0
	.'&'
	."\r\n";
	
	//==============
	
	//nombre de ticket pour l'aquit total sur 12mois
	$sql = "SELECT COUNT(*) as nbTocPourAquit1 FROM vm_durees_etapes a
		WHERE 1=1
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocPourAquit1 = $data['nbTocPourAquit1'];
		$strSorti .= $data['nbTocPourAquit1']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT COUNT(*) as nbTocAquit1 FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`time_aquit` <= '01:00:00'
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocAquit1 = $data['nbTocAquit1'];
		$strSorti .= $data['nbTocAquit1']
		.'&'
		."\r\n"; 
	}
	
	$percAquit1 = round(($nbTocAquit1 / $nbTocPourAquit1) * 100,2);
	$strSorti .= $percAquit1
	.'&'
	."\r\n";
	
	//==============
	
	//nombre de ticket pour l'aquit total sur 12mois
	$sql = "SELECT COUNT(*) as nbTocPourAquit2 FROM vm_durees_etapes a
		WHERE 1=1
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocPourAquit2 = $data['nbTocPourAquit2'];
		$strSorti .= $data['nbTocPourAquit2']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT COUNT(*) as nbTocAquit2 FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`time_aquit` <= '01:00:00'
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocAquit2 = $data['nbTocAquit2'];
		$strSorti .= $data['nbTocAquit2']
		.'&'
		."\r\n"; 
	}
	
	$percAquit2 = round(($nbTocAquit2 / $nbTocPourAquit2) * 100,2);
	$strSorti .= $percAquit2
	.'&'
	."\r\n";
	
	//==============
	
	//nombre de ticket pour l'aquit total sur 12mois
	$sql = "SELECT COUNT(*) as nbTocPourAquit3 FROM vm_durees_etapes a
		WHERE 1=1
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocPourAquit3 = $data['nbTocPourAquit3'];
		$strSorti .= $data['nbTocPourAquit3']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT COUNT(*) as nbTocAquit3 FROM vm_durees_etapes a
		WHERE 1=1
		AND a.`time_aquit` <= '01:00:00'
		AND date_format(a.`date_recept`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_recept` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocAquit3 = $data['nbTocAquit3'];
		$strSorti .= $data['nbTocAquit3']
		.'&'
		."\r\n"; 
	}
	
	$percAquit3 = round(($nbTocAquit3 / $nbTocPourAquit3) * 100,2);
	$strSorti .= $percAquit3
	.'&'
	."\r\n";
	
	//========================================================================= SLA
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1 = $data['nbTocP1'];
		$strSorti .= $data['nbTocP1']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1D' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D = $data['nbTocP1D'];
		$strSorti .= $data['nbTocP1D']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP1 = round(($nbTocP1D / $nbTocP1) * 100,2);
	$strSorti .= $percSLAP1
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP10' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP10 = $data['nbTocP10'];
		$strSorti .= $data['nbTocP10']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00'  
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D0 = $data['nbTocP1D0'];
		$strSorti .= $data['nbTocP1D0']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP10 = round(($nbTocP1D0 / $nbTocP10) * 100,2);
	$strSorti .= $percSLAP10
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP11' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP11 = $data['nbTocP11'];
		$strSorti .= $data['nbTocP11']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1D1' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D1 = $data['nbTocP1D1'];
		$strSorti .= $data['nbTocP1D1']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP11 = round(($nbTocP1D1 / $nbTocP11) * 100,2);
	$strSorti .= $percSLAP11
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP12' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP12 = $data['nbTocP12'];
		$strSorti .= $data['nbTocP12']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1D2' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D2 = $data['nbTocP1D2'];
		$strSorti .= $data['nbTocP1D2']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP12 = round(($nbTocP1D2 / $nbTocP12) * 100,2);
	$strSorti .= $percSLAP12
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP13' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP13 = $data['nbTocP13'];
		$strSorti .= $data['nbTocP13']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP1D3' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P1-Bloquant'
		AND b.duree_reel <= 480
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP1D3 = $data['nbTocP1D3'];
		$strSorti .= $data['nbTocP1D3']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP13 = round(($nbTocP1D3 / $nbTocP13) * 100,2);
	$strSorti .= $percSLAP13
	.'&'
	."\r\n";
	
	
	//========== P2
	
	
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP2' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2 = $data['nbTocP2'];
		$strSorti .= $data['nbTocP2']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP2D' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D = $data['nbTocP2D'];
		$strSorti .= $data['nbTocP2D']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP2 = round(($nbTocP2D / $nbTocP2) * 100,2);
	$strSorti .= $percSLAP2
	.'&'
	."\r\n";
	
	//=======
	
	//nb p2 mois 0
	$sql = "SELECT count(*) as 'nbTocP20' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP20 = $data['nbTocP20'];
		$strSorti .= $data['nbTocP20']
		.'&'
		."\r\n"; 
	}
	
	//nb p2 ferme dans SLA mois 0
	$sql = "SELECT count(*) as 'nbTocP2D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D0 = $data['nbTocP2D0'];
		$strSorti .= $data['nbTocP2D0']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP20 = round(($nbTocP2D0 / $nbTocP20) * 100,2);
	$strSorti .= $percSLAP20
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP21' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP21 = $data['nbTocP21'];
		$strSorti .= $data['nbTocP21']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP2D1' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D1 = $data['nbTocP2D1'];
		$strSorti .= $data['nbTocP2D1']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP21 = round(($nbTocP2D1 / $nbTocP21) * 100,2);
	$strSorti .= $percSLAP21
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP22' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP22 = $data['nbTocP22'];
		$strSorti .= $data['nbTocP22']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP2D2' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D2 = $data['nbTocP2D2'];
		$strSorti .= $data['nbTocP2D2']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP22 = round(($nbTocP2D2 / $nbTocP22) * 100,2);
	$strSorti .= $percSLAP22
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP23' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP23 = $data['nbTocP23'];
		$strSorti .= $data['nbTocP23']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP2D3' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND a.priorite = 'P2-Majeur'
		AND b.duree_reel <= 960
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP2D3 = $data['nbTocP2D3'];
		$strSorti .= $data['nbTocP2D3']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP23 = round(($nbTocP2D3 / $nbTocP23) * 100,2);
	$strSorti .= $percSLAP23
	.'&'
	."\r\n";
	
	//========== P3-4
	
	
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34 = $data['nbTocP34'];
		$strSorti .= $data['nbTocP34']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND a.`date_statut` between (now() - interval 1 year) and now()
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D = $data['nbTocP34D'];
		$strSorti .= $data['nbTocP34D']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP34 = round(($nbTocP34D / $nbTocP34) * 100,2);
	$strSorti .= $percSLAP34
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP340' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP340 = $data['nbTocP340'];
		$strSorti .= $data['nbTocP340']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D0' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 0 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D0 = $data['nbTocP34D0'];
		$strSorti .= $data['nbTocP34D0']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP340 = round(($nbTocP34D0 / $nbTocP340) * 100,2);
	$strSorti .= $percSLAP340
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP341' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP341 = $data['nbTocP341'];
		$strSorti .= $data['nbTocP341']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D1' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 1 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D1 = $data['nbTocP34D1'];
		$strSorti .= $data['nbTocP34D1']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP341 = round(($nbTocP34D1 / $nbTocP341) * 100,2);
	$strSorti .= $percSLAP341
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP342' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP342 = $data['nbTocP342'];
		$strSorti .= $data['nbTocP342']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D2' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 2 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D2 = $data['nbTocP34D2'];
		$strSorti .= $data['nbTocP34D2']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP342 = round(($nbTocP34D2 / $nbTocP342) * 100,2);
	$strSorti .= $percSLAP342
	.'&'
	."\r\n";
	
	//=======
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP343' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP343 = $data['nbTocP343'];
		$strSorti .= $data['nbTocP343']
		.'&'
		."\r\n"; 
	}
	
	//nombre de ticket aquité sur 12mois
	$sql = "SELECT count(*) as 'nbTocP34D3' FROM
		vm_inventaire_tocs a, vm_durees b
		WHERE 1=1
		AND a.id_toc = b.id_toc
		AND a.revision = 0
		AND a.emis != 'Oui'
		AND a.statut = 'Fermé'
		AND (a.priorite = 'P3-Mineur' or a.priorite = 'P4-Mineur')
		AND b.duree_reel <= 2400
		AND date_format(a.`date_statut`,'%y-%m') = date_format(now() - interval 3 MONTH,'%y-%m')
		AND a.`date_statut` < DATE_FORMAT(NOW(), '%Y-%m-%d')
		AND a.responsable in (SELECT c.responsable FROM `effectifs` c WHERE 1=1
			AND c.date_in != '0000-00-00' 
			AND c.date_out != '0000-00-00' 
			)
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		AND a.date_creation >= (SELECT STR_TO_DATE(param_value,'%Y-%m-%d') FROM tab_parametres c WHERE 1=1 AND c.param_name = 'date_hpas')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nbTocP34D3 = $data['nbTocP34D3'];
		$strSorti .= $data['nbTocP34D3']
		.'&'
		."\r\n"; 
	}
	
	$percSLAP343 = round(($nbTocP34D3 / $nbTocP343) * 100,2);
	$strSorti .= $percSLAP343
	.'&'
	."\r\n";
	
//---------------------------------------------------------	

	//=================================== reste
	//nombre de ticket restant sur 12mois
	$strSorti .= "0"
	.'&'
	."\r\n"; 
	
	//nombre de ticket restant le mois -1
	$strSorti .= "0"
	.'&'
	."\r\n"; 
	
	//nombre de ticket restant le mois -2
	$strSorti .= "0"
	.'&'
	."\r\n"; 
	
	//nombre de ticket restant le mois -3
	$strSorti .= "0"
	.'&'
	."\r\n"; 

//---------------------------------------------------------
	
	//nb jour ouvré
	$sql = "select count(*) as nombre from affectation
		where 1=1
		and open != close
		and date_format(`date`,'%Y-%m') = (select date_format(max(date),'%Y-%m') from affectation
		where 1=1
		and open != close
		and `date` < date_format(now(),'%Y-%m-%d'))
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nb_jour_ouvre =  $data['nombre']; 
	}
	
	//nb jour ouvré effectué
	$sql = "select count(*) as nombre from affectation
		where 1=1
		and open != close
		and date_format(`date`,'%Y-%m') = (select date_format(max(date),'%Y-%m') from affectation
			where 1=1
			and open != close
			and `date` < date_format(now(),'%Y-%m-%d'))
		and `date` < date_format(now(),'%Y-%m-%d')
	;";
		
	$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$nb_jour_ouvre_fait =  $data['nombre']; 
	}
	
	$ratio = $nb_jour_ouvre / $nb_jour_ouvre_fait;
	
	$strSorti .= $ratio
	.'&'
	."\r\n";
	
//---------------------------------------------------------

	//Nombre de ticket en stock CGI y compris retour pour le mois en cours
	$sql_stockCgi0 = "SELECT count(*) as `stockCgi0` 
		FROM `vm_inventaire_tocs` a
		where 1=1
		AND a.`emis` != 'Oui'
		AND a.statut in ('Demande d\'information','incomplète','Support/Déblocage','Demande injustifiée','Rejet demande')
		and a.date_creation < date_format(now(),'%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql_stockCgi0) or die('Erreur SQL !<br>'.$sql_stockCgi0.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$stockCgi0 = $data['stockCgi0'];
		$strSorti .= $data['stockCgi0']
		.'&'
		."\r\n"; 
	}
	
//---------------------------------------------------------

	//Nombre de ticket hors responsabilité CGI y compris retours
	$sql_horsStockCgi0 = "SELECT count(*) as `horsStockCgi0` 
		FROM `vm_inventaire_tocs` a
		where 1=1
		AND a.`emis` != 'Oui'
		AND a.statut not in ('Demande d\'information','incomplète','Support/Déblocage','Demande injustifiée','Rejet demande','Fermé')
		and a.date_creation < date_format(now(),'%Y-%m-%d')
		AND NOT EXISTS (select 1 from vm_inventaire_tocs_vsr z WHERE z.id_toc = a.id_toc)
		;";
		
	$req = mysql_query($sql_horsStockCgi0) or die('Erreur SQL !<br>'.$sql_horsStockCgi0.'<br>'.mysql_error()); 

	// on fait une boucle qui va faire un tour pour chaque enregistrement 
	while($data = mysql_fetch_assoc($req)) 
	{ 
		$horsStockCgi0 = $data['horsStockCgi0'];
		$strSorti .= $data['horsStockCgi0']
		.'&'
		."\r\n"; 
	}

	// DECONNECION SQL
	mysql_close();
	
	if($modeDebug){
		$strSorti .= ('<br><br><br><br>'.$sql_stockCgi0);
		$strSorti .= ('<br><br><br><br>'.$sql_horsStockCgi0);
	}
}else{
	$strSorti = "ERROR:".$arrayValeur["error"];
}

require("../API/php/footer.php");
?>